<script setup>
import {ref} from 'vue'

//语音开始标志
const flag=ref(false)

//语音开始
const handleVoiceStart=()=>{
	flag.value=true
}
//语音结束
const handleVoiceEnd=()=>{
	flag.value=false
}


</script>


<template>
	<view class="center">
		<!--语言快捷模式-->
		<view class="center-box">
			<view class="title">
				<image src="/static/voice.png" class="icon"></image>
				<view class="text">语言快捷模式</view>
			</view>
			<view class="voice-box">
				<!-- 修改后的语音按钮部分 -->
				<view class="voice-icon" @touchend="handleVoiceEnd" @touchstart="handleVoiceStart" :class="{ recording: isRecording }">
					<image src="/static/voice(1).png"></image>
					<!-- 波纹动画 -->
					<view :class="{'pulse-ring':flag}"></view>
					<view :class="{'pulse-ring':flag}" class="pulse-ring-delay-1"></view>
					<view :class="{'pulse-ring':flag}" class="pulse-ring-delay-2"></view>
				</view>
				<view class="tip">
					<view class="function">点击说话，快速挂号或咨询医生</view>
					<view class="text">例如："帮我挂心血管内科的号"</view>
				</view>
			</view>
		</view>
		<!--今日健康数据-->
		<view class="center-box">
			<view class="title">
				<image src="/static/love.png" class="icon"></image>
				<view class="text">今日健康数据</view>
			</view>
			<view class="data-box">
				<view class="rate">
					<view class="num">72</view>
					<view class="text">心率</view>
				</view>
				<view class="stress">
					<view class="num">120/80</view>
					<view class="text">血压</view>
				</view>
				<view class="Oxy">
					<view class="num">98%</view>
					<view class="text">血氧</view>
				</view>
			</view>
		</view>
		<!--今日饮食建议-->
		<view class="center-box">
			<view class="title">
				<image src="/static/food.png" class="icon"></image>
				<view class="text">今日饮食建议</view>
			</view>
			<view class="food-detail">
				<!--早餐-->
				<view class="breakfast">
					<view class="item">
						<image src="/static/breakfast.png"></image>
						<view class="text">早餐</view>
					</view>
					<view class="tip">燕麦粥1碗，水煮蛋1个，苹果半个低脂低糖，富含膳食纤维</view>
				</view>
				<!--午餐-->
				<view class="lunch">
					<view class="item">
						<image src="/static/lunch.png"></image>
						<view class="text">午餐</view>
					</view>
					<view class="tip">糙米饭1小碗，清蒸鱼150g，西兰花100g优质蛋白，控制盐分摄入</view>
				</view>
				<!--晚餐-->
				<view class="dinner">
					<view class="item">
						<image src="/static/dinner.png"></image>
						<view class="text">晚餐</view>
					</view>
					<view class="tip">小米粥1碗，蒸南瓜100g，凉拌木耳50g易消化，富含微量元素</view>
				</view>
			</view>
		</view>
		<!--核心功能-->
		<view class="center-box">
			<view class="title">
				<image src="/static/save.png" class="icon"></image>
				<view class="text">核心功能</view>
			</view>
			<view class="core-function">
				<view class="func-item">
					<view class="img">
						<image src="/static/phone.png"></image>
					</view>
					<view class="title">语言挂号</view>
					<view class="tip">通过语音指令快速完成挂号，支持多家三甲医院，自动匹配适合的科室和医生。</view>
					<view class="btn"><button>立即体验</button></view>
				</view>
				<view class="func-item">
					<view class="img">
						<image src="/static/diagnose.png"></image>
					</view>
					<view class="title">线上问诊</view>
					<view class="tip">与专业医生视频或图文交流，描述症状获取专业建议，支持处方开具和药品配送。</view>
					<view class="special-btn"><button>咨询医生</button></view>
				</view>
				<view class="func-item">
					<view class="img">
						<image src="/static/health.png"></image>
					</view>
					<view class="title">健康监测</view>
					<view class="tip">连接智能手环实时监测心率、血压、血氧等数据，异常情况自动预警并建议就医。</view>
					<view class="btn"><button>查看详情</button></view>
				</view>
			</view>
		</view>

	</view>
</template>


<style lang="scss" scoped>
	.center {

		.center-box {
			padding: 20rpx;

			.title {
				display: flex;
				align-items: center;

				image {
					width: 50rpx;
					height: 50rpx;

				}

				.text {
					margin-left: 15rpx;
					color: rgb(106, 144, 201);
					font-weight: 600;
					font-size: 32rpx;
					letter-spacing: 1rpx;
				}
			}

			image {
				width: 51rpx;
				height: 51rpx;
			}

			.voice-box {
				position: relative;
				display: flex;
				align-items: center;
				top: 15rpx;
				.tip{
					margin-left: 15rpx;
					.function{
						font-size: 26rpx;
					}
					.text{
						font-size: 20rpx;
					}
					
				}
				.voice-icon {
					
					position: relative;
					width: 85rpx;
					height: 85rpx;
					border-radius: 50%;
					background-color: rgb(255, 120, 88);
					display: flex;
					align-items: center;
					justify-content: center;
					margin-left: 30rpx;
					transition: all 0.3s ease;
					z-index: 2;

					image {
						width: 40rpx;
						height: 40rpx;
						transition: transform 0.3s ease;
					}

					// 录音状态的样式
					&.recording {
						background-color: #ff4c4c;
						box-shadow: 0 0 20rpx rgba(255, 76, 76, 0.5);

						image {
							transform: scale(1.2);
						}
					}

					// 波纹动画效果
					.pulse-ring {
						position: absolute;
						width: 100%;
						height: 100%;
						border-radius: 50%;
						background-color: rgba(255, 120, 88, 0.5);
						opacity: 0;
						z-index: 1;
						animation: pulse 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
					}

					.pulse-ring-delay-1 {
						animation-delay: 0.66s;
					}

					.pulse-ring-delay-2 {
						animation-delay: 1.33s;
					}

					@keyframes pulse {
						0% {
							transform: scale(0.8);
							opacity: 0.7;
						}

						70% {
							transform: scale(1.5);
							opacity: 0;
						}

						100% {
							opacity: 0;
						}
					}
				}
			}

			.data-box {
				margin: 30rpx 60rpx;
				display: flex;
				justify-content: space-between;

				.num {
					color: rgb(106, 144, 201);
					font-weight: 700;
					font-size: 35rpx;
				}

				.text {
					margin-top: 17rpx;
					font-size: 23rpx;
				}

				.rate,
				.Oxy {
					flex-direction: column;
					display: flex;
					justify-content: center;
					text-align: center;
					width: 25%;
					background-color: rgb(249, 249, 249);
					height: 150rpx;
					border-radius: 10rpx;
				}

				.stress {
					flex-direction: column;
					display: flex;
					justify-content: center;
					text-align: center;
					width: 35%;
					background-color: rgb(249, 249, 249);
					height: 150rpx;
					border-radius: 10rpx;
				}

			}

			.food-detail {

				height: 500rpx;
				margin: 20rpx auto;
				border-radius: 15rpx;
				border: 1px solid #eee;
				box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
				width: 85%;
				padding: 30rpx 20rpx;

				.breakfast,
				.lunch,
				.dinner {
					margin-bottom: 60rpx;
				}

				.item {
					display: flex;
					align-items: center;

					image {
						width: 35rpx;
						height: 35rpx;
					}

					.text {
						margin-left: 10rpx;
						color: rgb(105, 145, 196);
						font-weight: 700;
						font-size: 24rpx;
					}
				}

				.tip {
					margin: 20rpx 20rpx;
					margin-left: 55rpx;
					width: 75%;
					font-size: 26rpx;
				}
			}

		}

		.core-function {
			margin-top: 20rpx;

			.func-item {
				margin: 20rpx auto;
				width: 85%;
				height: 450rpx;
				border: 1px solid #eee;
				box-shadow: -8rpx 0 12rpx -2rpx rgba(255, 120, 88, 0.6);
				border-radius: 10rpx;
				padding: 30rpx;

				view {
					margin-top: 35rpx;

				}

				.img {
					display: flex;
					align-items: center;
					justify-content: center;
					border-radius: 50%;
					width: 100rpx;
					height: 100rpx;
					background-color: rgb(213, 226, 242);
				}

				.title {
					font-weight: 700;
				}

				.tip {
					font-size: 26rpx;
				}

				.btn,
				.special-btn {
					button {
						display: flex;
						align-items: center;
						width: 200rpx;
						border-radius: 20rpx;
						height: 70rpx;
						font-size: 26rpx;
						justify-content: center;
						background: rgb(107, 144, 196);
						color: white;
						margin-left: 0;

					}
				}

				.special-btn {
					button {
						background-color: rgb(255, 120, 88);
					}
				}

			}
		}
	}
</style>